﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using ZGDev.FormSpark;
using ZGDev.FormSpark.AnimationCurves;

namespace Wpf_Sample
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            Animator.InitWithWPFPanel((Panel)this.Content);

            AnimationContext bgAnim = new AnimationContext(AnimationCurve.Linear);
            bgAnim.Curve.SetDuration(3.0f);
            bgAnim.AddAnimation<Window1, Color>(this, Color.FromArgb(255, 150, 150, 255), "BackColor");
            bgAnim.Reverses = true;
            bgAnim.Loops = true;

            Animator.Run("BackColor Anim", bgAnim);
        }

        public Color BackColor
        {
            get
            {
                return ((SolidColorBrush)this.Background).Color;
            }
            set
            {
                this.Background = new SolidColorBrush(value);
            }
        }

        private void bigBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!Animator.IsAnimationRunning("ButtonAnim"))
            {
                AnimationContext btnAnim = new AnimationContext();
                btnAnim.Curve.SetDuration(2.0f);
                btnAnim.AddAnimation<Button, double>(this.bigBtn, 250.0, "Width");
                btnAnim.AddAnimation<Button, double>(this.bigBtn, 200.0, "Height");
                btnAnim.Reverses = true;

                Animator.Run("ButtonAnim", btnAnim);
            }
        }
    }
}
